package com.zp.demo.repush.listener;

import com.zp.demo.repush.event.RepayPlanEvent;
import com.zp.demo.repush.service.defined.DefindSendEmailService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/**
 * 发送邮件的监听
 * @Author 张鹏
 * @Date 2018/12/29 16:57
 */

@Component
@Log4j2
public class SendEmailListener implements ApplicationListener<RepayPlanEvent> {
    @Autowired
    private DefindSendEmailService sendEmailService;
    @Override
    public void onApplicationEvent(RepayPlanEvent event) {
        if(sendEmailService == null){
            log.debug("没有配置发送邮件");
        }else{
            sendEmailService.sendEmail(event.getRePushVo());
        }
    }
}
